<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>信达数据中心运维管理自动化平台</title>
    <meta name="keywords" content="信达数据中心运维管理自动化平台">
    <meta name="description" content="信达数据中心运维管理自动化平台">
    <link rel="shortcut icon" href="../../favicon.ico">
    <link href="../../../css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="../../../css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="../../../css/animate.css" rel="stylesheet">
    <!-- Data Tables -->
    <link href="../../../css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link href="../../../css/plugins/dataTables/buttons.dataTables.min.css" rel="stylesheet">
    <link href="../../../css/style.css?v=4.1.0" rel="stylesheet">

    <style type="text/css">

    </style>

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox">
                    <div class="ibox-title">
                        <h5>配置数量统计页面报表</h5>
                    </div>
                    <div class="ibox-content">
                        <div class="tabs-container">
                            <div class="tab-content">
                                <div id="tab-tabale1" class="tab-pane active">
                                    <div class="panel-body" style="border: 1px solid #ffffff;">

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 基础js -->
    <script src="../../../js/jquery.min.js?v=2.1.4"></script>
    <script src="../../../js/bootstrap.min.js?v=3.3.6"></script>
    <script src="../../../js/content.js?v=1.0.0"></script>

    <!-- 插件js -->
    <script src="../../../js/handlebars-v3.0.1.js"></script>
    <!-- Data Tables -->
    <script src="../../../js/plugins/dataTables/jquery.dataTables.js"></script>
    <script src="../../../js/plugins/dataTables/dataTables.bootstrap.js"></script>
    <script src="../../../js/plugins/dataTables/dataTables.buttons.min.js"></script>
    <script src="../../../js/plugins/dataTables/jszip.min.js"></script>
    <script src="../../../js/plugins/dataTables/buttons.html5.min.js"></script>


    <script id="tpl" type="text/x-handlebars-template">

        {{! 表格模板 }}
        <table class="table table-striped table-bordered table-hover dataTables">
            <thead>
                <tr>
                    {{#each thead}}
                    <th>{{this}}</th>
                    {{/each}}
                </tr>
            </thead>
            <tfoot>
                <tr>
                    {{#each tfoot}}
                    <th>{{this}}</th>
                    {{/each}}
                </tr>
            </tfoot>
        </table>

    </script>

    <script type="text/javascript">
        $(function () {

            // ---------- handlebars模板 ----------
            var tpl = $("#tpl").html();
            var template = Handlebars.compile(tpl);
            var context = {
                "thead": ["类别", "子类", "条目", "状态", "数量"],
                "tfoot": ["类别", "子类", "条目", "状态", "数量"]
            };
            var html = template(context);
            $(".panel-body").html(html);

            // ---------- dataTables表格 ----------
            var table = $('.dataTables').DataTable({
                "dom": "Bfrtip",
                "ajax": '../../../data/dt.json',
                "columns": [
                    { "data": "id1" },
                    { "data": "id2" },
                    { "data": "id3" },
                    { "data": "id4" },
                    { "data": "id5" }
                ],
                initComplete: function () {
                    var api = this.api();
                    api.columns().indexes().flatten().each(function (i) {
                        var column = api.column(i);
                        var select = $('<select><option value=""></option></select>')
                            .prependTo($(column.header()).prepend("<br><br>"))
                            .on('change', function () {
                                var val = $.fn.dataTable.util.escapeRegex(
                                    $(this).val()
                                );
                                column
                                    .search(val ? '^' + val + '$' : '', true, false)
                                    .draw();
                            });
                        column.data().unique().sort().each(function (d, j) {
                            select.append('<option value="' + d + '">' + d + '</option>')
                        });
                    });
                },
                "buttons": [
                    {
                        text: '返回',
                        action: function (e, dt, node, config) {
                            window.location.href = '../report_conf.html';
                        }
                    },
                    {
                        extend: 'excelHtml5',   // 使用excele扩展
                        text: '导出数据',       // 显示文字
                        customize: function (xlsx) {
                            var sheet = xlsx.xl.worksheets['sheet1.xml'];
                            $('row c[r^="C"]', sheet).attr('s', '2');
                        }
                    },
                    {
                        text: '刷新',
                        action: function (e, dt, node, config) {
                            location.reload();
                        }
                    }
                ]
            });

        })
    </script>
</body>

</html>